
package com.joysuch.wwyt.bp.enums;

public enum PendingTaskType {

    INSPECT_PLAN("InspectPlan", "巡检计划") ,
    WORK_APPROVE("WorkApprove", "作业审批") ,
    WORK_APPLY("WorkApply", "特殊作业") ,
    WORK_ACCEPT("WorkAccept", "作业验收") ,
    HD_RECTIFY("HDRectify", "整改管理") ,
    HD_ACCEPT("HDAccept", "整改验收");

    private String code;
    private String name;

    private PendingTaskType(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static PendingTaskType findByName(String name) {
        PendingTaskType[] values = PendingTaskType.values();
        for (PendingTaskType v : values) {
            if (v.getName().equals(name)) {
                return v;
            }
        }
        return null;
    }

    public static PendingTaskType findByCode(String code) {
        PendingTaskType[] values = PendingTaskType.values();
        for (PendingTaskType v : values) {
            if (v.getCode().equals(code)) {
                return v;
            }
        }
        return null;
    }

    public static String findNameByCode(String code) {
        PendingTaskType types = findByCode(code);
        return types == null ? null : types.name;
    }
}
